<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var name = 'xiaomi'
        var obj = {
            name: 'redmi',
            getName () {  // 没有闭包
                return function() {
                    return this.name
                }
            }
        }
        console.log(obj.getName()())  // xiaomi

        var name1 = 'xiaomi'
        var obj1 = {
            name1: 'redmi',
            getName () {
                var thiss = this   // 有闭包
                return function() {
                    return thiss.name1
                }
            }
        }
        console.log(obj1.getName()())  // redmi 
    </script>
</body>
</html>